

$(function () {
    layui.use('laypage', function(){
        var count = $("#count").text();
        var curr = $("#curr").text();
        var key = $("#searchbox").val();
        var category_name = $("#category_name").text();
        var tag = $("#tag").text();
        var laypage = layui.laypage;
        laypage.render({
            elem: 'blogs'
            ,layout:['prev', 'page', 'next','skip']
            ,count: count //数据总数，从服务端得到
            ,curr:curr
            ,jump: function(obj, first){
                //obj包含了当前分页的所有参数，比如：
                //console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
                //console.log(obj.limit); //得到每页显示的条数
                if(!first){

                    if(!isNull(key)){
                        window.location.href="/blog/search/page?page="+obj.curr+"&limit="+obj.limit+"&key="+key;
                    }else if(!isNull(category_name)){
                        window.location.href="/blog/category/page?page="+obj.curr+"&limit="+obj.limit+"&category_name="+category_name;
                    }else if(!isNull(tag)){
                        window.location.href="/blog/tag/page?page="+obj.curr+"&limit="+obj.limit+"&tag="+tag;
                    }
                    else{
                        window.location.href="/blog/page?page="+obj.curr+"&limit="+obj.limit;
                    }
                }


            }
        });
    });








})


